/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dnstry;

/**
 *
 * @author Claudiu
 */
public class DnsSendStream {
    byte [] stream;
      public DnsSendStream(String address,boolean inverse){

       DnsHeader head = new DnsHeader();
       DnsQuestion question = new DnsQuestion(/*"www.google.com"*/ address,inverse);
       if (inverse)
       {

           question.setIp();
           
       }
       head.buildHeader(inverse);
       byte [] questionByte  = new byte[512];
       byte [] headerByte  = new byte[head.headerSize +1];
       questionByte = question.getDnsQuestion();
       headerByte =head.getHeaderContent();
       stream = new byte[head.headerSize+question.length];
       for ( int i=0;i<head.headerSize ;i++)
       {
            System.out.print(" "+headerByte[i]);
            stream[i]= headerByte[i];
       }
       System.out.println();
              System.out.println("ql "+question.length);
       for( int i=0;i<question.length;i++)
       {
          
            System.out.print(" "+questionByte[i]);
            stream[i+head.headerSize] =questionByte[i];
       }
      }
      public byte [] getStream()
      {
          return stream;
      }
}
